package com.tai.network;

import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * The type Inet address demo.
 *
 * @author taylor
 * @Description: 网络编程demo
 * @date 2021 /6/23 21:59
 */
public class InetAddressDemo {

    /**
     * Test.
     *
     * @throws UnknownHostException the unknown host exception
     */
    @Test
    public  void test() throws UnknownHostException {
        //获取ip
        InetAddress inet1 = InetAddress.getByName("localhost");
        System.out.println(inet1);
        InetAddress inet2 = InetAddress.getLocalHost();
        System.out.println(inet2);
        InetAddress inet3 = InetAddress.getLoopbackAddress();
        System.out.println(inet3);


    }

}
